<template>
<onekit-page>
<onekit-view onekit-class="container">
	<div is="onekit-template-head" :DATA="`${JSON.stringify({title:'getBatteryInfo'})}`"></div>
	<onekit-view onekit-class="page-body">
		<onekit-view onekit-class="page-section">
			<onekit-view onekit-class="weui-cells weui-cells_after-title">
				<onekit-view onekit-class="weui-cell weui-cell_input">
					<onekit-view onekit-class="weui-cell__hd">
						<onekit-view onekit-class="weui-label">当前电量</onekit-view>
					</onekit-view>
					<onekit-view onekit-class="weui-cell__bd">
						<onekit-input onekit-class="weui-input" type="text" :disabled="true" placeholder="未获取" :value="level"></onekit-input>
					</onekit-view>
				</onekit-view>
				<onekit-view onekit-class="weui-cell weui-cell_input">
					<onekit-view onekit-class="weui-cell__hd">
						<onekit-view onekit-class="weui-label">电池模式</onekit-view>
					</onekit-view>
					<onekit-view onekit-class="weui-cell__bd">
						<onekit-input onekit-class="weui-input" type="text" :disabled="true" placeholder="未获取" :value="isCharging"></onekit-input>
					</onekit-view>
				</onekit-view>
			</onekit-view>
			<onekit-button type="primary" @Tap="getBatteryInfo">获取电量信息信息</onekit-button>
		</onekit-view>
	</onekit-view>
	<div is="onekit-template-foot"></div>
</onekit-view>
</onekit-page></template>
<script>
/* eslint-disable */
import Vue from 'vue';
import onekit_template_0 from '../../../common/head.head.vue';Vue.component('onekit-template-head',onekit_template_0);
import onekit_template_1 from '../../../common/foot.foot.vue';Vue.component('onekit-template-foot',onekit_template_1);
const ONEKIT_JSON= {
  "navigationBarTitleText": "获取手机设备电量",
  "usingComponents": {
    
  }
};
const ONEKIT_SJS = {
};
import wx from '../../../../weixin2vue/wx.js';
import Macro from '../../../../weixin2vue/Macro.js';
const {getApp,getCurrentPages} = Macro;
import Page from '../../../../weixin2vue/OnekitPage.js';
import Component from '../../../../weixin2vue/OnekitComponent.js';
export default Page(ONEKIT_JSON,["true","level","isCharging"],ONEKIT_SJS,{
    "onShareAppMessage"(){
      return {
        "title":'获取电池信息',
        "path":'packageAPI/pages/get-battery-info/get-battery-info'
};
    },
    "data":{
},
    "getBatteryInfo"(){
      wx.getBatteryInfo({
        "complete":(res)=>{
          const msg = res.isCharging?'充电中':'使用电池中';
          this.setData({
              "level":res.level,
              "isCharging":msg
});
        }
});
    }
});

</script>
<style 
 lang="css">
@import '/common/lib/weui.css';
</style>